package com.cloud.DrugManagement.pojo.vo;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhozixiong
 * @date 2023/02/24
 */
@Data
public class PageVo<T> {
    /**
     * 当前页码
     */
    private Integer pageIndex;
    /**
     * 当前页最大长度
     */
    private Integer pageSize;
    /**
     * 总数
     */
    private Integer total;
    /**
     * 总页数
     */
    private Integer pages;
    /**
     * 当前页数据
     */
    private List<T> data;

    public PageVo(List<T> data, Integer pageIndex, Integer pageSize, Integer countSize) {
        this.data = data;
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.total = countSize;
        this.pages = countSize % pageSize == 0 ? countSize / pageSize : countSize / pageSize + 1;
    }

    public PageVo() {
        this.data = new ArrayList<>();
        this.pageIndex = 1;
        this.pageSize = 10;
        this.total = 0;
        this.pages = 0;
    }
}
